/*-------------------------------------------------------------------------
***************** Modification History ***********************************
   @doc
   @module format.c - Data formating functions |
   @end

$Log: /SoftPay/SPK2SIM/Source/Utils/format.c $
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#define VSFORMAT_C

#include <aclconio.h>
#include <stdio.h>
#include <ascii.h>
#include <stdlib.h>
#include <aclstr.h>
#include <string.h>
#include <ctype.h>

#include <project.h>
#ifdef DEBUG_VSFORMAT
#define DEBUG_95
#endif

#include <define.h>
#include <format.h>
#include <spdebug.h>
#include <cst.h>
#include <cdt.h>
#include <hdt.h>
#include <tct.h>
#include <iit.h>
#include <tblutil.h>
#include <msgfuncs.h>
#include <msg.h>

#if defined (_VSC)
#include <date.h>
#endif

int inParseBuffer(char* pchBuf,char chSep,char* pVarPtrs[]) {
    char* pchDest = '\0';
    char* pchSrc;
    int i,
    j;

    *pchDest = '\0';

    pchSrc = pchBuf;

    i = 0;
    while (pVarPtrs[i] != NULL) {
        pchDest = pVarPtrs[i];
        for (j = 0; *pchSrc != chSep && *pchSrc; j++)
            *pchDest++ = *pchSrc++ ;

        *pchDest = '\0';
        i++;

        if (*pchSrc != chSep)
            break;
        pchSrc++;
    }

    return(i);
}


/*
 * All trailing spaces from a string is removed
 */

void vdTrimSpaces(char* pchString) {
    int inIndex;

    while (1) {
        inIndex = strlen(pchString);
        if (inIndex) {
            if (pchString[inIndex - 1] == SPACE) {
                pchString[inIndex - 1] = NULL_CH;
                continue;
            }
        }
        break;
    }
}

/*
 * All leading spaces from a string is removed, string is a null terminated
 * string.
 */
void vdTrimLeadSpaces(char* pchString) {
    int inIndex;

    inIndex = 0;
    while (pchString[inIndex] == SPACE)
        inIndex++;
    if (inIndex != 0)
        strcpy(pchString, &(pchString[inIndex]));
}

/*
 * All leading spaces from a string is removed, string is a null terminated
 * string.
 */
void vdTrimLeadZeroes(char* pchString) {
    int inIndex;

    inIndex = 0;
    while (pchString[inIndex] == '0')
        inIndex++;
    if (inIndex != 0)
        strcpy(pchString, &(pchString[inIndex]));
}

/*
 *  Purpose : This function places the Decimal point at DEC_POSN.(counting
 *             from right to left,starting with 1)
 *             eg A) if inDecPosn = 3
 *                     and the  string passed is "1",
 *                     the returned string is   "0.01"
 *
 *             eg B) if inDecPosn = 4
 *                     and the string passed is "11",
 *                     the returned string is   "0.011"
 *             eg C) if inDecPosn = 3
 *                     and the string passed is "1111111",
 *                     the returned string is   "11111.11"
 *
 */

void vdFormatPerCent(char* pchAmt,int inFractionalSize) {
    char chDecChar;
    int inLen,
    inDecPosn/*, inPunctStyle*/;
    int inMinusSign;

    /**pdebug (("---in vdFormatPerCent---"));**/
    //  inDecPosn = inGetDecPosn ();      /* Get the # of decimal places */
    inDecPosn = inFractionalSize + 1;      /* Get the # of decimal places */
    /**pdebug (("inDecPosn = %d", inDecPosn));**/
    //  inPunctStyle = inGetAmtPunctStyle();
    /**pdebug (("inPunctStyle = %d", inPunctStyle));**/

    /* Refer to SVC_KEY_NUM for this values */
    //  chDecChar = ((inPunctStyle == 0) || (inPunctStyle == 2)) ? '.' : ',';
    chDecChar = '.';

    if (pchAmt[0] == '-')
        inMinusSign = 1;
    else
        inMinusSign = 0;

    inLen = strlen(&pchAmt[inMinusSign]);

    //  if (fGetDispDecDigits() == VS_FALSE)
    //  {
    //      /* Make sure that amounts that are less than $1 with no decimal */
    //      /* display just print a zero */
    //      inLen = inLen+inMinusSign-MAX_DECIMAL_DIGITS;
    //      if (inLen <= 0)
    //      {
    //          pchAmt[0] = '0';
    //          inLen = 1;
    //      }
    //        pchAmt[inLen] = '\0';
    //        /* If we only have a minus sign then just print/display zero */
    //        if (inLen == 1 && pchAmt[0] == '-')
    //          pchAmt[0] = '0';
    //
    //  } /* end if HDT Disp Dec Digits == FALSE */
    //  else
     {
        if (inLen < inDecPosn) {
            pad(&pchAmt[inMinusSign], &pchAmt[inMinusSign], '0', inDecPosn, RIGHT);
            inLen = strlen(&pchAmt[inMinusSign]);
        }
        if (inDecPosn > 1)
            insert_char(pchAmt, (inLen + inMinusSign - (inDecPosn - 1)), chDecChar);
    }
}

/*************************************************************************************************
*
*   The following code has been extracted from a CVision library, it therefore does not reflect
*   the coding standards of SoftPay. All code except is contained within this block of code.
*   Simon_h2    2nd Feb 2000
*
*************************************************************************************************/
#define CURRENCY_SYMBOL         'C'
#define CURRENCY_SYMBOL_NO_PAD  'c'
#define NUMERIC_VALUE           'N'
#define NUMERIC_VALUE_NO_PAD    'n'

char formatAmt(char* into,char* amt,char* currency,char* format,VS_BOOL print) {
    int n,
    writePos;
    int max;
    int amtCount = strlen(amt) - 1;
    int currencyCount = strlen(currency) - 1;
    int nCount = 0;
    int addNs = 0;
    char seenANoPad = 0;
    char forcePad = 0;
    char formatstring[FORMATTED_AMOUNT_SIZE + 1];
    char newAmt[FORMATTED_AMOUNT_SIZE + 1];
    VS_BOOL first = VS_TRUE;

    /* Don't want to change original format because the caller uses it later */
    memset(formatstring, 0x00, sizeof(formatstring));
    strcpy(formatstring, format);

    /* Don't want to change original amt because the caller uses it later */
    memset(newAmt, 0x00, sizeof(newAmt));
    strcpy(newAmt, amt);

    for (n = 0, max = strlen(formatstring); n < max; n++) {
        if (formatstring[n] == NUMERIC_VALUE || formatstring[n] == NUMERIC_VALUE_NO_PAD) {
            if (first) {
                /* If this is our first n then mark it so we can */
                /* insert before it */
                first = VS_FALSE;
                writePos = n;
            }
            /* count how many numeric digits */
            nCount++;
        } /* end if numeric digit */
    } /* end for all of the chars in formatstring */

    /* we are probably printing on a receipt or report and we want to */
    /* make sure we print all of the numeric digits */
    if ((amtCount + 1) > 0 && print) {
        if ((amtCount + 1) > nCount) {
            addNs = (amtCount + 1) - nCount;
            if ((strlen(formatstring) + addNs) <= FORMATTED_AMOUNT_SIZE)
                for (n = addNs; n > 0; n--) {
                    insert_char(formatstring, writePos, NUMERIC_VALUE_NO_PAD);
                } /* end if we have room in the formatstring string */
        } /* end if we need more room to print the numbers in the amount */
    } /* if amount count is greater than zero */


    /* If we have a negative amount don't print it next to the last digit */
    /* print it after the padding so that NNN,NNN.NN won't look like */
    /* $ 000,0-5.00     instead it will look like  $ -00,005.00  */
    if (newAmt[0] == '-') {
        formatstring[writePos] = '-';
        /* Don't print the negative from the amt string, print from formatstring */
        strcpy(newAmt, &newAmt[1]);
        amtCount--;
    }


    for (n = 0, max = strlen(formatstring); n < max && !forcePad; n++) {
        if (formatstring[n] == CURRENCY_SYMBOL)
            forcePad = 1;
        if (formatstring[n] == NUMERIC_VALUE || formatstring[n] == NUMERIC_VALUE_NO_PAD)
            break;  /* No Pad Force required if currency after amount */
    }
    into[strlen(formatstring)] = '\0';
    for (writePos = n = strlen(formatstring) - 1; n >= 0; n--) {
        switch (formatstring[n]) {
        case CURRENCY_SYMBOL:
        case CURRENCY_SYMBOL_NO_PAD:
            if (currencyCount >= 0)
                into[writePos--] = currency[currencyCount--];
            break;
        case NUMERIC_VALUE:
            if (amtCount < 0) {
                if (seenANoPad) {
                    if (forcePad)
                        into[writePos--] = ' ';
                } else
                    into[writePos--] = '0';
            } else
                into[writePos--] = newAmt[amtCount--];
            break;
        case NUMERIC_VALUE_NO_PAD:
            if (amtCount < 0) {
                if (forcePad)
                    into[writePos--] = ' ';
            } else
                into[writePos--] = newAmt[amtCount--];
            seenANoPad = 1;
            break;
        case ',':
        case '.':
            if (formatstring[n - 1] == NUMERIC_VALUE_NO_PAD && amtCount < 0)
                seenANoPad = 1; // Shouldn't be a ',' if no character printed after it !!
            if (!seenANoPad || (amtCount >= 0 && newAmt[amtCount] != '-'))
                into[writePos--] = formatstring[n];
            else if (forcePad)
                into[writePos--] = ' ';
            break;
        default:
            into[writePos--] = formatstring[n];
            break;
        }
    }
    if (writePos >= 0)
        memmove(into, &into[writePos + 1], strlen(formatstring) - writePos + 1);
    return  amtCount <= 0;  // Returns 1 if amount fully expressed
}


void MaskingMerchant(int Type, char * inpt,char *Output)
{
   char buff[16];
   memset(buff,0x00, sizeof buff);

   switch (Type)
   	{
   	 case 1:// TID
	 	    memcpy(buff,inpt,8);
		    memcpy(&buff[4],"XXXX",4);	
		    memcpy(Output,buff,8);	
	 	break;
	  case 2: // MID
	 	    memcpy(buff,inpt,15);
		    memcpy(&buff[11],"XXXX",4);	
		    memcpy(Output,buff,15);	
	        
	  	break;
   	}
   
   
}


/*-------------------------------------------------------------------------
    Function :     vdFormatAmount
    Description :
        Formats an amount string by padding zeroes, padding spaces in the begining
        etc. The size of the amount string is defined as AMT_STR_SIZE. Also puts
        decimal point at the proper posn.
    Parameters :
    Returns :
    Globals :
    Notes :
    Modification History :
      #     Date      Who                     Description
    ----- -------- ---------- ---------------------------------------------
      1   06/09/95  Henry_G1   Eliminated the padding of spaces.
--------------------------------------------------------------------------*/

void vdFormatAmount(char* pchAmt,VS_BOOL fPutSymbol) {
    char szCurSym[CUR_SYMBOL_SIZE + 1];
    char szLocAmt[FORMATTED_AMOUNT_SIZE + 1];

    /** /pdebug(("--vdFormatAmount--"));*/


    if ((strlen(pchAmt) <= 3) && (str2int(pchAmt) < 0)/* && (fGetDispDecDigits() == VS_TRUE) */)
        sprintf(&pchAmt[1], "%03li", (-1L) * str2long(pchAmt));


    if (fPutSymbol)
        strcpy(szCurSym, szGetCurSymbol());
    else
        memset(szCurSym, 0x00, CUR_SYMBOL_SIZE);
    strlcpy(szLocAmt, pchAmt, FORMATTED_AMOUNT_SIZE);
    formatAmt(pchAmt, szLocAmt, szCurSym, szGetAmountFormat(), VS_TRUE);
    /*  if ((strlen (pchAmt) == 0) || (strlen (pchAmt) > FORMATTED_AMOUNT_SIZE))
            return ;

        vdPutDecPoint(pchAmt);
        vdGetCSTCurSymbol(szCurSym);

        sprintf(szLocAmt, "%s %s", szCurSym, pchAmt);

        strlcpy(pchAmt, szLocAmt, FORMATTED_AMOUNT_SIZE);*/
}


void vdFormatPAN(TRANSACTION_OBJECT* pobTran,char* pchPAN,char* pchFmtPAN,int inFmtPANSize) {
    char szFmt[FORMATTED_PAN_SIZE + 1];
    char szScratch[FORMATTED_PAN_SIZE + 1];
    char szCurrentPAN[FORMATTED_PAN_SIZE + 1];
    char chLastPad = ' ';
    VS_BOOL fReverseMode = VS_FALSE;
    VS_BOOL fMerchFormat = VS_FALSE;
    int inBytesLeft;
    int inLen;
    int inLastDigits;
    int inFmtIdx = 0;
    int inPANIdx = 0;
    int i = 0;

    	

    /* Remove 1 from count for NULL terminator, assume caller uses sizeof */
    inFmtPANSize--;


    memset(szFmt, 0x00, sizeof(szFmt));

    if (inGetIssuerRecord(inGetIssuerNum()) == VS_SUCCESS) {
        strcpy(szFmt, szGetPANFormat());
        fMerchFormat = fGetMerchPANFormat();
    }

    if (strlen(szFmt) == 0 || (pobTran->srBRec.inPrintOption & PRT_MERCH && fMerchFormat == VS_FALSE)) {
        /* No formatting so print the entire account # */
        strlcpy(pchFmtPAN, pchPAN, inFmtPANSize);
        return;
    }

    /* First check on reverse mode, only indicated by first byte */
    memset(szCurrentPAN, 0x00, sizeof(szCurrentPAN));
    if (szFmt[inFmtIdx] == 'R' || szFmt[inFmtIdx] == 'r') {
        fReverseMode = VS_TRUE;
        inFmtIdx++;  /* Move past the 'r' */
        inBytesLeft = inLen = strlen(pchPAN);
        inBytesLeft--;  /* array index starts at 0 */
        for (i = 0; i < inLen && i < FORMATTED_PAN_SIZE; i++,inBytesLeft--) {
            /* Copy the PAN backwards */
            szCurrentPAN[i] = *(pchPAN + inBytesLeft);
        }
    } /* end if reverse mode */
    else
        strlcpy(szCurrentPAN, pchPAN, FORMATTED_PAN_SIZE); /* end else normal mode */


    /* While rcpt.acctnum not full && ! end of PAN  && ! end of Format string */
    while (szFmt[inFmtIdx] != NULL_CH && szCurrentPAN[inPANIdx] != NULL_CH && strlen(pchFmtPAN) < inFmtPANSize) {
        if (szFmt[inFmtIdx] == 'n' || szFmt[inFmtIdx] == 'N') {
            /* They want this one digit in full view */
            append_char(pchFmtPAN, szCurrentPAN[inPANIdx]);
            inFmtIdx++;
            inPANIdx++;
            if (szFmt[inFmtIdx] == NULL_CH)
                inFmtIdx--;
        } /* end if n or N, print PAN digit */
        else if (szFmt[inFmtIdx] == 'X' || szFmt[inFmtIdx] == 'x' || szFmt[inFmtIdx] == '*') {
            /* They want one pad character */
            append_char(pchFmtPAN, szFmt[inFmtIdx]);
            chLastPad = szFmt[inFmtIdx];
            inFmtIdx++;
            inPANIdx++;
            if (szFmt[inFmtIdx] == NULL_CH) {
                /* No more formatting so print the rest w/ pads */
                inBytesLeft = strlen(&szCurrentPAN[inPANIdx]);
                memset(szScratch, 0x00, sizeof(szScratch));
                pad(szScratch, szScratch, chLastPad, inBytesLeft, RIGHT);
                strcat(pchFmtPAN, szScratch);
            }
        } /* end if pad character (x,X or * ) */
        else if (!isdigit(szFmt[inFmtIdx])) {
            /* They want a format separator */
            append_char(pchFmtPAN, szFmt[inFmtIdx]);
            inFmtIdx++;
        } /* end if not 0-9 */
        else if (szFmt[inFmtIdx] == '0') {
            /* Zero is not a valid value */
            inFmtIdx++;
        } /* end if zero */
        else {
            /* We must have 1-9 in szFmt[inFmtIdx] */
            inBytesLeft = strlen(&szCurrentPAN[inPANIdx]);
            inLastDigits = chars2int(&szFmt[inFmtIdx], 1);

            /* if we are reverse mode the last digits are in the front.
             if we are not in reverse then if what we have left in the PAN
             is less than or equal to the LastDigit PAN Format indicator
             if either is true then print a PAN digit in the open */
            if ((fReverseMode && inPANIdx < inLastDigits) || (!fReverseMode && inBytesLeft <= inLastDigits)) {
                append_char(pchFmtPAN, szCurrentPAN[inPANIdx]);
                inFmtIdx++;
                inPANIdx++;
                if (fReverseMode && (inPANIdx < inLastDigits || szFmt[inFmtIdx] == NULL_CH)) {
                    /* Still have more PAN digits to print */
                    inFmtIdx--;
                }
                if (szFmt[inFmtIdx] == NULL_CH) {
                    /* No more formatting so print the rest of the PAN */
                    strcat(pchFmtPAN, &szCurrentPAN[inPANIdx]);
                }
            } /* if last x digits then print the PAN in the open */
            else {
                /* If we are not at the end of PAN then print the last pad char */
                if (chLastPad != ' ')
                    append_char(pchFmtPAN, chLastPad);
                inFmtIdx++;
                inPANIdx++;
                /* if that was our last format character then use it again */
                if (szFmt[inFmtIdx] == NULL_CH)
                    inFmtIdx--;
            } /* end if PAN remaining greater than last digit indicator */
        } /* end else, must be 1-9 */
    } /* end while print buffer not full, not end of Format string or PAN */

    if (fReverseMode) {
        memset(szScratch, 0x00, sizeof(szScratch));
        inBytesLeft = inLen = strlen(pchFmtPAN);
        inBytesLeft--;  /* array index starts at 0 */
        for (i = 0; i < inLen && i < FORMATTED_PAN_SIZE; i++,--inBytesLeft) {
            /* Copy the Formatted PAN back so that it is forward */
            szScratch[i] = *(pchFmtPAN + inBytesLeft);
        }
        strlcpy(pchFmtPAN, szScratch, FORMATTED_PAN_SIZE);
    } /* end if reverse mode */


    return;
} /* end func vdFormatPAN() */



/*************************************************************************************************
*
*   The following code has been extracted from a CVision library, it therefore does not reflect
*   the coding standards of SoftPay. All code except structure defintions and function prototypes
*   which are in the format.h file are contained within this block of code.
*   Simon_h2    2nd Feb 2000
*
*************************************************************************************************/
#include <ctype.h>

#define  DAY_INDICATOR                      'D'
#define  MONTH_INDICATOR                    'M'
#define  YEAR_INDICATOR                     'Y'

#define SUPPORT_MONTHNAME       /* Support month names within date formats */

#ifdef SUPPORT_MONTHNAME
char* monthname[12] = {
    "January",
    "Feburary",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
};
#endif

static void pad_string(char* str,int padlen,char padval,int padtype) {
    int padno;

    if ((padno = padlen - strlen(str)) > 0) {
        if (padtype == LEFT)
            memmove(str + padno, str, strlen(str) + 1);
        else
            str += strlen(str);
        memset(str, padval, padno);
        if (padtype == RIGHT)
            *(str + padno) = '\0';
    } else if (padno < 0) {
        // Truncate string if too long!!
        memmove(str, str + abs(padno), padlen + 1);
    }
}

static void num_datetime_to_string(char** str,char** format,int val) {
    int count;
    char template_ch = **format;
    char padChar = isupper(template_ch) ? '0' : ' ';

    for (count = 0; toupper(**format) == toupper(template_ch);) {
        (*format)++;
        count++;
    }
    int2str(*str, val);
    pad_string(*str, count, padChar, LEFT);
    *str += strlen(*str);
}

static int extract_numeric_data(char* str,unsigned int no) {
    int val = 0;

    while (isdigit(*str) && no-- > 0)
        val = (val * 10.0) + (int) ((*(str++) - '0'));
    return(val);
}
static unsigned int transfer_data(char** str,char** format) {
    int count;
    char* ptr;
    char template_ch = **format;

    for (count = 0,ptr = *str; **format == template_ch; (*str)++, (*format)++)
        count++;
    return((unsigned int) (extract_numeric_data(ptr, count)));
}

#ifdef SUPPORT_MONTHNAME
static void num_mon_to_name(char** str,char** format,int val) {
    int count;
    char* ptr,
    template_ch = **format;

    for (count = 0; toupper(**format) == toupper(template_ch);) {
        (*format)++;
        count++;
    }
    if (val > 0 && val <= 12)
        for (ptr = monthname[val - 1]; *ptr != '\0' && count-- > 0;)
            *((*str)++) = *(ptr++);
}
#endif

void date_to_string(char* str,char* format,struct date_type* buffer) {
    char day;

    while (*format != '\0')
        switch (toupper(*format)) {
        case DAY_INDICATOR:
            day = buffer->day;
            num_datetime_to_string(&str, &format, buffer->day);
            break;
        case MONTH_INDICATOR:
#ifdef SUPPORT_MONTHNAME
            if (toupper(*(format + 2)) == toupper(MONTH_INDICATOR))
                num_mon_to_name(&str, &format, buffer->month);
            else
            #endif
                num_datetime_to_string(&str, &format, buffer->month);
            break;
        case YEAR_INDICATOR:
            num_datetime_to_string(&str, &format, buffer->year);
            break;
        default:
            *(str++) = *(format++);
        }
    *str = '\0';
}

struct date_type* string_to_date(char* str,char* format) {
    static struct date_type buffer;
    char* tmp;

    buffer.day = buffer.month = buffer.year = 0;
    while (*format != '\0')
        switch (toupper(*format)) {
        case DAY_INDICATOR:
            buffer.day = transfer_data(&str, &format);
            break;
        case MONTH_INDICATOR:
            buffer.month = transfer_data(&str, &format);
            break;
        case YEAR_INDICATOR:
            tmp = format;
            buffer.year = transfer_data(&str, &format);
            if ((format - tmp) <= 2) {
                if (buffer.year < 70)
                    buffer.year += 2000;
                else
                    buffer.year += 1900;
            }
            break;
        default:
            format++;
            str++;
        }
    return(&buffer);
}

/**************************************************************************
 *
 * End of CVision code block
 *
 **************************************************************************/


/*-------------------------------------------------------------------------
    Function :     vdFormatDate
    Description :
     Converts from YYMMDD to MM/DD/YY format if Date format = 0
     else converts to DD/MM/YY format BUG235


    Parameters :
    Returns :
    Globals :
    Notes :
    Modification History :
      #     Date      Who                     Description
    ----- -------- ---------- ---------------------------------------------
      1   10/11/96 Pat_G1     If date is MMDD format, get the current YY.
      2   10/13/98 Monique_B1 Change second date option to YYMMDD
      3   30/01/00 Simon_h2     Changed mechanism so that date formating is now based on a 'format'
--------------------------------------------------------------------------*/

void vdFormatDate(char* pchDate) {
    char szLocal[DATE_SIZE + 10];
    struct date_type* date;

    if (strlen(pchDate) == 4) {
        /*
         * get YYMMDD date, save the YY portion.
         */
        vdGetDate(szLocal, 0);
        strcpy(&szLocal[2], pchDate);
    } else
        strcpy(szLocal, pchDate);
    // Convert szLocal into form YYMMDD into date structure
    date = string_to_date(szLocal, "YYMMDD");
    // Now convert date structure into TCT date format
    date_to_string(pchDate, szGetDateFormat(), date);
}



/* Converts from HHMMSS to HH:MM:SS format */
void vdFormatTime(char* pchTime) {
    char szLocal[TIME_SIZE + 1];

    strcpy(szLocal, pchTime);
    sprintf(pchTime, "%.2s:%.2s:%.2s", szLocal, &(szLocal[2]), &(szLocal[4]));
}

/*-------------------------------------------------------------------------
    Function :     vdPurgeStrofChars
    Description :
        Removes an string of chars. from a given string.

    Parameters :  pchInString : string to be modified
                  pchCharstoRemove : set of chars. to remove from string
    Returns :     none
    Globals :     none
    Notes :
    Modification History :
      #     Date      Who                     Description
    ----- -------- ---------- ---------------------------------------------
      1   07/20/95  Ana_C1     Created
--------------------------------------------------------------------------*/

void vdPurgeStrofChars(char* pchInString,char* pchCharstoRemove) {
    char* pchPtr;

    pchPtr = pchCharstoRemove;

    while (*pchPtr) {
        purge_char(pchInString, *pchPtr);
        pchPtr++;
    }
    return;
}

#undef VSFORMAT_C

/** Function prototypes - not called anywhere,,,
int inParseBuffer (char *pchBuf,char chSep, char *pVarPtrs[]);
void vdTrimSpaces (char *pchString);
void vdTrimLeadSpaces (char *pchString);
void vdTrimLeadZeroes (char *pchString);
void vdRemDecPoint (char *pchAmt);
void vdPutDecPoint (char *pchAmt);
void vdFormatAmount (char *pchAmt);
void vdFormatPAN (char *pchPAN,char *pchFmtPAN, int inFmtPANSize);
void vdFormatDate (char *pchDate);
void vdFormatTime (char *pchTime);
void vdPurgeStrofChars (char *pchInString,char *pchCharstoRemove);


**/
